def solve(points):
    points.sort(key=lambda x: x[1])
    res = 1
    cur = points[0][1]
    for l, r in points[1:]:
        if l > cur:
            res += 1
            cur = r

    return res


if __name__ == "__main__":
    points = [[10, 16], [2, 8], [1, 6], [7, 12]]
    print(solve(points))
